/**
 * 武汉天瑞兴科技有限公司
 */
package com.adds.lvds.security.acegi;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;

/**
 *项目名称 ：lvds-web-security
 *@author zhangjian
 *@time 2016-8-12上午11:32:25
 */
public class LoginAuthenticationFailureHandler implements AuthenticationFailureHandler {
	 
		private String defaultUrl;
		public void setDefaultUrl(String defaultUrl) {
			this.defaultUrl = defaultUrl;
		}
		@Override
		public void onAuthenticationFailure(HttpServletRequest request,
				HttpServletResponse response, AuthenticationException exception)
				throws IOException, ServletException {
			String errorMSG=exception.getMessage();
	        request.setAttribute("errorMSG", errorMSG);
	        request.getRequestDispatcher(defaultUrl).forward(request, response);
	    }  


}
